package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ModuleDataFileDao;
import com.sugon.entity.ModuleDataFileEntity;
import com.sugon.service.ModuleDataFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import static com.sugon.utils.ShiroUtils.getUserId;

/**
 * 模具资料--附件关联Service实现类
 *
 * @author sugon
 * @date 2019-07-31 14:38:51
 */
@Service("moduleDataFileService")
public class ModuleDataFileServiceImpl implements ModuleDataFileService {
    @Autowired
    private ModuleDataFileDao moduleDataFileDao;

    @Override
    public ModuleDataFileEntity queryObject(String id) {
        return moduleDataFileDao.queryObject(id);
    }

    @Override
    public List<ModuleDataFileEntity> queryList(Map<String, Object> map) {
        return moduleDataFileDao.queryList(map);
    }

    @Override
    public List<ModuleDataFileEntity> queryModuleList(Map<String, Object> map) {
        return moduleDataFileDao.queryModuleList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return moduleDataFileDao.queryTotal(map);
    }

    @Override
    public int save(ModuleDataFileEntity moduleDataFile) {
        moduleDataFile.setId(RandomUtil.randomString(32));
        moduleDataFile.setCreateUser(getUserId());
        moduleDataFile.setCreateTime(DateUtil.date());
        return moduleDataFileDao.save(moduleDataFile);
    }

    @Override
    public int update(ModuleDataFileEntity moduleDataFile) {
        moduleDataFile.setUpdateUser(getUserId());
        moduleDataFile.setUpdateTime(DateUtil.date());
        return moduleDataFileDao.update(moduleDataFile);
    }

    /**
     * delete
     *
     * @param id
     * @return
     */
    @Override
    public int delete(String id) {
        return moduleDataFileDao.delete(id);
    }

    /**
     * deleteBatch
     *
     * @param ids
     * @return
     */
    @Override
    public int deleteBatch(String[] ids) {
        return moduleDataFileDao.deleteBatch(ids);
    }
}
